package com.atwulidun.factory02.factorymethod.order;

import com.atwulidun.factory02.factorymethod.pizza.Pizza;

import java.util.Scanner;

public class OrderPizza {
    public static void orderPizza() {
        Scanner scanner = new Scanner(System.in);
        String input;
        while (true) {
            System.out.println("请输入要订购哪个地方的披萨：");
            input = scanner.next();
            if (input.equals("Beijing")) {
                while (true) {
                    System.out.println("请输入要订购的披萨的口味：");
                    input = scanner.next();
                    if (input.equals("Cheese")) {
                        // 创建一个北京芝士披萨工厂
                        BeijingCheesePizzaFactory beijingCheesePizzaFactory = new BeijingCheesePizzaFactory();
                        printProcedure(beijingCheesePizzaFactory);
                        break;
                    } else if (input.equals("Pepper")) {
                        // 创建一个北京胡椒披萨工厂
                        BeijingPepperPizzaFactory beijingPepperPizzaFactory = new BeijingPepperPizzaFactory();
                        printProcedure(beijingPepperPizzaFactory);
                        break;
                    }
                }
            } else if (input.equals("London")) {
                while (true) {
                    System.out.println("请输入要订购的披萨的口味：");
                    input = scanner.next();
                    if (input.equals("Cheese")) {
                        // 创建一个伦敦芝士披萨工厂
                        LondonCheesePizzaFactory londonCheesePizzaFactory = new LondonCheesePizzaFactory();
                        printProcedure(londonCheesePizzaFactory);
                        break;
                    } else if (input.equals("Pepper")) {
                        // 创建一个伦敦胡椒披萨工厂
                        LondonPepperPizzaFactory londonPepperPizzaFactory = new LondonPepperPizzaFactory();
                        printProcedure(londonPepperPizzaFactory);
                        break;
                    }
                }
            }
        }
    }
    // 打印出pizza制作流程的方法
    public static void printProcedure(PizzaFactory pizzaFactory) {
        Pizza pizza = pizzaFactory.createPizza();
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
    }
}
